// 黑名单
import request from "@/utils/request";

export default {
  getBlackList(searchModel) {
    return request({
      url: "/blacklist/list",
      method: "get",
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        username: searchModel.username,
        phone: searchModel.phone,
      },
    });
  },

  addBlackUser(blacklist) {
    return request({
      url: "/blacklist",
      method: "post",
      data: blacklist,
    });
  },

  getBlackUserById(id) {
    return request({
      url: `/blacklist/${id}`,
      method: "get",
    });
  },

  saveBlackUser(blacklist) {
    if (blacklist.id == null && blacklist.id == undefined) {
      return this.addBlackUser(blacklist);
    }
    return this.updateBlackUser(blacklist);
  },

  updateBlackUser(blacklist) {
    return request({
      url: `/blacklist`,
      method: "put",
      data: blacklist,
    });
  },

  deleteBlackUserById(id) {
    return request({
      url: `/blacklist/${id}`,
      method: "delete",
    });
  },
};
